<template>
    <!-- 设置 -->
    <div class="settingBox">
        <x-header :left-options="{showBack: true,backText:'设置'}" class="headerBox"></x-header>
        <router-link to="/personalData" class="userInfos">
            <div class="userInfo">
                <img v-if="userInfo.largeAvatar !=''" :src="userInfo.largeAvatar" />
                <img v-else src="../assets/images/avatar.png" />
                <div class="userContent">
                    <div class="userName">
                      {{userInfo.nickName}}
                        <img src="../assets/images/girl01.png"/>
                    </div>
                    <div class="userID">用户名：{{userInfo.nickName}}</div>
                </div>
            </div>
            <img src="../assets/images/unfold011.png" class="more"/>
        </router-link>
        <group class="switchGroup" style="display: none">
            <x-switch title="允许使用2G/3G/4G下观看视频" v-model="switchStatus"></x-switch>
        </group>

        <div class="setList" style="display: none">
            <div>清除缓存</div>
            <div>30M</div>
        </div>
        <router-link to class="setList" style="display: none">
            <div>评价</div>
            <div>
                <img src="../assets/images/answer32.png"/>
            </div>
        </router-link>
        <router-link :to="{name:'passwordEdit',query:{name:userInfo.id}}" class="setList">
            <div>修改密码</div>
            <div>
                <img src="../assets/images/answer32.png"/>
            </div>
        </router-link>
        <router-link to="/contactUs" class="setList" style="display: none">
            <div>联系我们</div>
            <div>
                <img src="../assets/images/answer32.png"/>
            </div>
        </router-link>
        <router-link to="/aboutUs" class="setList">
            <div>关于我们</div>
            <div>
                <img src="../assets/images/answer32.png"/>
            </div>
        </router-link>
        <div class="signOut" @click="hreftwo()">退出登录</div>
    </div>
</template>

<script>
    import {XHeader, XSwitch, Group} from "vux";
    import {userInfo} from '@/api/index/index';

    import store from "../store/store";

    export default {
        components: {
            XHeader,
            XSwitch,
            Group
        },
        data() {
            return {
                switchStatus: false,
                userId: '',
                userInfo: '',
            }
        },
        mounted() {
            userInfo(this.$store.state.user.id).then(res => {
              console.log(res.data.data);
                this.userInfo = res.data.data.userInfo;
                this.userId = res.data.data.userInfo.id;
            }).catch(err => {
                console.log(err)
            });
        },
        methods: {
            hreftwo() {
                this.$store.commit('LOGOUT');
                // console.log(this.$store.state.user.name);
                // console.log(this.$store.state.user.id);
                // console.log(this.$store.state.user.tenantId);
                this.$router.push("/");

            },
        }
    }
</script>

<style lang="less" scoped>
    .settingBox {
        // 头部导航
        /deep/ .headerBox {
            background-color: #fff;
            border-bottom: 1px solid #eee;

            .vux-header-left {
                left: 24px;

                .vux-header-back {
                    color: #000;
                }

                .left-arrow:before {
                    border-color: #000;
                }
            }
        }

        .userInfos {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: #fff;
            color: currentColor;
            padding: 30px;

            .userInfo {
                display: flex;
                align-items: center;

                img {
                    width: 140px;
                    height: 140px;
                }

                .userContent {
                    margin-left: 20px;

                    .userName {
                        font-size: 30px;
                        font-weight: 600;
                        margin-bottom: 15px;
                    }

                    img {
                        width: 19px;
                        height: 19px;
                        margin-left: 10px;
                    }

                    .userID {
                        font-size: 26px;
                        color: #757575;
                    }
                }
            }

            .more {
                width: 32px;
                height: 32px;
            }
        }

        /deep/ .switchGroup {
            border-bottom: 20px solid #f8f9fa;

            .vux-no-group-title {
                margin-top: 0;
            }

            .weui-label {
                font-size: 30px;
            }
        }

        .setList {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 20px 30px;
            background: #fff;
            font-size: 30px;
            border-bottom: 1px solid #f0f1f1;
            color: currentColor;

            img {
                width: 24px;
                height: 24px;
            }

            div:last-child {
                color: #8a8c8e;
            }
        }

        .signOut {
            position: fixed;
            bottom: 100px;
            left: 80px;
            right: 80px;
            font-size: 32px;
            border-radius: 8px;
            line-height: 2.5;
            background: #3477e7;
            color: #fff;
            text-align: center;
        }
    }
</style>